package com.igroupes.ovineherd.model.utils;

import cn.hutool.core.convert.Convert;
import com.igroupes.ovineherd.model.Style.Group;
import com.igroupes.ovineherd.model.Style.RadioStyle;

import java.util.ArrayList;
import java.util.List;

public class RadioUtils {
    /**
     * 获得所有选中值
     * @param o
     * @return
     */
    public static List<String> fields(Object o){
        RadioStyle style = (RadioStyle) o;
        List<String> stringList = new ArrayList<>();
        if(!style.getDisabled()){
            for (Object g :
                    style.getOptions()) {
                Group group1 = (Group) g;
                if(!group1.getDisabled() && group1.getChecked()){
                    stringList.add(Convert.toStr(group1.getValue()));
                }
            }
        }
        return stringList;
    }
}
